# coding=utf-8
import os

from inter_auto.script.base_api import BaseApi


class WeWork(BaseApi):

    # 继承父类
    def __init__(self):
        super().__init__()
        self.get_token_url = "https://qyapi.weixin.qq.com/cgi-bin/gettoken"
        # self.get_token_data = {
        #     "corpid": "wwbea39a8fef8b2988",
        #     "corpsecret": "qTOrt5_Gmt8IvdSO8fdPxbB9faW8c7b3WgUyzQlKSgA"
        # }
        env = os.getenv('env', default='test')
        self.cfg_data = self.get_cfg_data()
        self.get_token_data = self.cfg_data.get(env)


    # 获取token
    def get_token(self):

        res = self.get(self.get_token_url, params=self.get_token_data).json()
        token = res.get("access_token")
        return token


if __name__ == '__main__':
    wework = WeWork()
    print(wework.get_token_data)
    token = wework.get_token()
    print(token)

